package com.market.member.service.impl;

import cn.hutool.core.util.StrUtil;
import com.block.common.bean.CommonParam;
import com.block.common.bean.SessionBean;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.MemberFeedback;
import com.block.db.mapper.MemberFeedbackMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.market.member.service.IMemberFeedbackService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2022-08-23
 */
@Service
public class MemberFeedbackServiceImpl extends ServiceImpl<MemberFeedbackMapper, MemberFeedback> implements IMemberFeedbackService {

    @Override
    public ResponseVo saveInfo(Long uid, String content, String mobile, SessionBean sessionBean, CommonParam commonParam) {

        if (StrUtil.isEmpty(mobile)){
            mobile = sessionBean.getMobile();
        }

        MemberFeedback memberFeedback = new MemberFeedback();
        memberFeedback.setUid(uid);
        memberFeedback.setContent(content);
        memberFeedback.setMobile(mobile);

        memberFeedback.setChannelCode(sessionBean.getChannelCode());
        memberFeedback.setChannelName(sessionBean.getChannelName());
        memberFeedback.setReqChannelCode(commonParam.getChannelCode());
        memberFeedback.setReqChannelName(commonParam.getChannelName());

        this.save(memberFeedback);
        return new ResponseVo(AppRspCodeConstant.SUCCESS);
    }
}
